import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;


/**
 * @author Tsarev Oleg<br/>
 *		   <b>mail:</b> tsarev.oi@mail.ru<br/>
 *         <b>date:</b> 13.07.2010<br/>
 *         <b>time:</b> 16:17:34
 *
 */
public class Inserter {

	public static void main(String[] args) throws IOException {
		if (args.length<3) {
			throw new RuntimeException("Not enought parameters...");
		}
		
		File source1 = new File(args[0]);
		File source2 = new File(args[1]);
		File target = new File(args[2]);
		target.createNewFile();
		BufferedWriter fw = new BufferedWriter(new FileWriter(target));
		
		if (source1.exists()) {
			BufferedReader fr = new BufferedReader(new FileReader(source1));
			
			String line;
			while ((line=fr.readLine())!=null) {
					fw.write(line);
					fw.newLine();
			}
			fr.close();
			
		} else {
			throw new RuntimeException("Source file not exists...");
		}
		
		if (source2.exists()) {
			BufferedReader fr = new BufferedReader(new FileReader(source2));
			
			String line;
			while ((line=fr.readLine())!=null) {
					fw.write(line);
					fw.newLine();
			}
			fr.close();
			
		} else {
			throw new RuntimeException("Source file not exists...");
		}
		
		fw.flush();
		fw.close();

	}

}
